package com.nbsaas.boot.wms.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "库存调整", model = "库存调整")
@Entity
@Table(name = "bs_inventory_adjustment")
@Comment("库存调整表")
public class InventoryAdjustment extends AbstractEntity {

    @Comment("调整单号")
    @SearchItem(name = "adjustmentNo", key = "adjustmentNo", label = "调整单号")
    @FormField(title = "调整单号", sortNum = "1", grid = true, required = true)
    @Column(length = 100, nullable = false, unique = true)
    private String adjustmentNo;

    @Comment("调整类型")
    @FormField(title = "调整类型", sortNum = "2", grid = true, type = InputType.select)
    @Column(length = 20)
    private String type; // INVENTORY-盘点调整, DAMAGE-报损调整, LOSS-丢失调整, OTHER-其他调整

    @Comment("仓库ID")
    @FormField(title = "仓库ID", sortNum = "3", grid = true, required = true)
    private Long warehouseId;

    @Comment("商品ID")
    @FormField(title = "商品ID", sortNum = "4", grid = true, required = true)
    private Long productId;

    @Comment("SKU ID")
    @FormField(title = "SKU ID", sortNum = "5", grid = true, required = true)
    private Long skuId;

    @Comment("货位ID")
    @FormField(title = "货位ID", sortNum = "6", grid = true)
    private Long locationId;

    @Comment("调整前数量")
    @FormField(title = "调整前数量", sortNum = "7", grid = true, type = InputType.el_input_number)
    private Integer beforeQuantity;

    @Comment("调整后数量")
    @FormField(title = "调整后数量", sortNum = "8", grid = true, type = InputType.el_input_number)
    private Integer afterQuantity;

    @Comment("调整数量")
    @FormField(title = "调整数量", sortNum = "9", grid = true, type = InputType.el_input_number, sort = true)
    private Integer adjustmentQuantity;

    @Comment("单位成本")
    @FormField(title = "单位成本", sortNum = "10", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal unitCost;

    @Comment("调整金额")
    @FormField(title = "调整金额", sortNum = "11", grid = true, type = InputType.el_input_number, sort = true)
    @Column(precision = 10, scale = 2)
    private BigDecimal adjustmentAmount;

    @Comment("批次号")
    @FormField(title = "批次号", sortNum = "12", grid = true)
    @Column(length = 100)
    private String batchNo;

    @Comment("调整原因")
    @FormField(title = "调整原因", sortNum = "13", grid = true)
    @Column(length = 500)
    private String reason;

    @Comment("调整单状态")
    @FormField(title = "调整单状态", sortNum = "14", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // DRAFT-草稿, PENDING-待审核, APPROVED-已审核, COMPLETED-已完成, CANCELLED-已取消

    @Comment("审核人ID")
    @FormField(title = "审核人ID", sortNum = "15", grid = true)
    private Long approverId;

    @Comment("审核时间")
    @FormField(title = "审核时间", sortNum = "16", grid = true, type = InputType.date)
    private Date approveTime;

    @Comment("审核备注")
    @FormField(title = "审核备注", sortNum = "17", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String approveNote;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "18", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String note;
} 